package cn.stylefeng.guns.modular.service.impl;

import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.entity.IdjLists;
import cn.stylefeng.guns.modular.mapper.IdjListsMapper;
import cn.stylefeng.guns.modular.mapper.IdjListsUserMapper;
import cn.stylefeng.guns.modular.service.IIdjListsService;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.ModelAndView;

/**
 * <p>
 * 榜单表 服务实现类
 * </p>
 *
 * @author TANGWJ
 * @since 2020-07-30
 */
@Service
public class IdjListsServiceImpl extends ServiceImpl<IdjListsMapper, IdjLists> implements IIdjListsService {

	@Autowired
	private IdjListsMapper mapper;
	
	@Autowired
	private IdjListsUserMapper userMapper;
	
	@Override
	public LayuiPageInfo getList(Page<IdjLists> page, String keyword, String beginTime, String endTime, String aa,
			String bb, String cc, Integer lx,String yes,String no) {
		Page<Map<String,Object>> list = mapper.getList(page, keyword, beginTime, endTime, aa, bb, cc, lx, yes, no);
		return LayuiPageFactory.createPageInfo(list);
	}

	@Override
	public ModelAndView edit(Long listsId) {
		IdjLists lists = mapper.selectByKeyId(listsId);
		if (lists != null) {
			if(lists.getListsId() != null){
				lists.setUserlist(userMapper.selectByKeyId(listsId));
			}
		}
		ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("lists", lists);
        return modelAndView;
	}

	@Override
	public int setStatus(IdjLists lists) {
		return mapper.setStatus(lists);
	}

	@Override
	public int insert(IdjLists lists) {
		return mapper.insert(lists);
	}

}
